const { injectBabelPlugin } = require("react-app-rewired");
const rewireLess = require("react-app-rewire-less");

module.exports = function override(config, env) {

    config = injectBabelPlugin(
        ["import", { libraryName: "antd", libraryDirectory: "es", style: true }],
        config
    );
    config = injectBabelPlugin(
        ["import", {
            libraryName:             "ant-design-pro",
            libraryDirectory:        "lib",
            style:                   true,
            camel2DashComponentName: false
        }, "ant-design-pro"],
        config
    );

    // config = rewireMobx(config, env);
    // config = injectBabelPlugin("transform-decorators-legacy", {"legacy": true}, config);
    config = injectBabelPlugin(["@babel/plugin-proposal-decorators", { legacy: true }], config);

    const primaryColor = "#DB4527";
    config = rewireLess.withLoaderOptions({
        modifyVars:        {
            "@primary-color":             primaryColor,
            "@info-color":                primaryColor,
            "@processing-color":          primaryColor,
            "@layout-header-background ": "#fff"
        },
        javascriptEnabled: true
    })(config, env);
    return config;
};
